#include "clcomcommand.h"
#include "CCommand.h"

CLComCommand::CLComCommand()
{
    CCommand* pcmd = new CCommand;
    m_pData = pcmd;
}
CLComCommand::~CLComCommand()
{
    CCommand* pcmd = (CCommand*)m_pData;
    delete pcmd;
    pcmd = nullptr;
    m_pData = nullptr;
}

void CLComCommand::SetCommandKey(const char* commandkey)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetCommandKey(commandkey);
    }
}
void CLComCommand::SetCommandType(const char* commandkey)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetCommandKey(commandkey);
    }
}
void CLComCommand::SetParameteInt(const char* name, int nValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetParameteInt(name, nValue);
    }
}
void CLComCommand::SetParameteBigInt(const char* name, qint64 llValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetParameteBigInt(name, llValue);
    }
}
void CLComCommand::SetParameteDouble(const char*  name, double dValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetParameteDouble(name, dValue);
    }
}
void CLComCommand::SetParameteString(const char*  name, const char*  strValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetParameteString(name, strValue);
    }
}
void CLComCommand::SetOtherData(const char* name, void* pData, int nDatalen)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->SetOtherData(name, pData, nDatalen);
    }
}

const char* CLComCommand::GetCommand()
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetCommand();
    }
    return nullptr;
}
int CLComCommand::GetCommandSize()
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetCommandSize();
    }
    return 0;
}
int CLComCommand::GetKVStrSize()
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetKVStrSize();
    }
    return 0;
}
bool CLComCommand::GetKVStr(
    char* pOutStr,
    int nCapacityLen)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetKVStr(pOutStr, nCapacityLen);
    }
    return false;
}
void CLComCommand::GetKeys(
    char* argKeys[],
    int &nCount)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetKeys(argKeys, nCount);
    }
}
void CLComCommand::ReleaseKeys(char* argKeys[], int nCount)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->ReleaseKeys(argKeys, nCount);
    }
}

void CLComCommand::Assignment(const char* commandstr)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->Assignment(commandstr);
    }
}

void CLComCommand::AssignmentKV(const char* commandstr)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->AssignmentKV(commandstr);
    }
}


int CLComCommand::GetCommandType()
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetCommandType();
    }
    return -1;
}
const char* CLComCommand::GetCommandKey()
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetCommandKey();
    }
    return "";
}
int CLComCommand::GetParameteInt(const char* name, int nDefaultValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetParameteInt(name, nDefaultValue);
    }
    return nDefaultValue;
}
double CLComCommand::GetParameteDouble(const char*  name, double dDefaultValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetParameteDouble(name, dDefaultValue);
    }
    return dDefaultValue;
}
const char* CLComCommand::GetParameteString(const char*  name, const char*  strDefaultValue)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetParameteString(name, strDefaultValue);
    }
    return strDefaultValue;
}
const char* CLComCommand::GetOtherData(const char*  name, int& nDataLen)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->GetOtherData(name, nDataLen);
    }
    nDataLen = 0;
    return "";
}
bool CLComCommand::HaveAttribute(const char* name)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        return pcmd->HaveAttribute(name);
    }
    return false;
}

void CLComCommand::Data2File(FILE* pFile)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->Data2File(pFile);
    }
}
void CLComCommand::LoadFromFile(FILE* pFile, int nLen)
{
    CCommand* pcmd = (CCommand*)m_pData;

    if (pcmd)
    {
        pcmd->LoadFromFile(pFile, nLen);
    }
}
